dev branch to finally complete the basic unit handling logic#39
dev branch to finally complete the basic unit handling logic#39
Conversation
…own units in relation to existing units
…y, as this overwrites % itself; we have to create our own unit for it
…es that emerged with the introduction of at% and wt%
…th information on each column, 2. creating the respective constructor functions
…s in the column names
|
What I implemented here so far:
At this point I think it would be very important to test intensively. Overall this seems to be workable, but it's also a bit brittle. We need to know the edge cases, either to address them, or at least to work around them. So the three big ToDos I see right now are:
|
|
Thank you so much, @nevrome, this all looks awesome. I played a bit around with it and it seems to work fine. I lacked the headspace of writing proper tests, sorry. I would expect that the ID column is created by renaming the respective column rather than making a copy of it. Is there a reason for this behaviour? |
|
Found a potential bug: I tried to connect wt% to the udunits so that except at% and oxide% all units can be handled with the package results in (focus on The behavior occurs here, and deactivating this if-statement in the underlying constructor function disables it (because it disables assignment of units in general). I was not able to figure out the reason. I suspected that You have to restart the R session and reload the package to reproduce the bug. It seems that only "load_all()" does not reset the units defined on package load. |
|
I looked at your changes with 2cbbc68...a69aebe - I didn't know that there would be so much special notation to be mapped, but good that you have a solid overview here. I'll look into the bug you describe now. I have the suspicion that I ran into this as well three weeks ago. Looks familiar. |
|
Ok - so I can reproduce your observation and I still vaguely remember that I encountered the same issue. Afaik this has something to do with overwriting the unitless unit without a custom base. That's what you effectively do with Following this issue here, I think there must be a solution. Looking at the help file of
So far I have left the definition of "mass_basis" empty. When I instead set it explicitly to I'm not sure, though, if this covers what you have in mind. You write
But we already handle all units with udunits, even at%. It just has this custom base which makes it sort of incompatible with other units. But that is unavoidable, right? |
|
I added my change in 3255fa2 with some more comments on this mechanism. |
This was imprecise phrasing from my side, sorry. I meant "udunits doing the conversion", i.e. without the need for dedicated conversion functions. And yes, they are unavoidable for these special cases. Thanks! I will look into the details and your commit later today. |
Welcome to the inconsistency of reporting... some are now outdated, some prefer writing with parentheses and others without. I tried to cover them all 🤷 |
Works as intended 😊 |
This would be handy for columns created in functions to be then included in an archchem object.
I created this as a development branch for @archaeothommy and me (and whoever would like to join) to work on the archchem class and its missing core features (see e.g. #12, #18, #20).